<%@page import="java.util.StringTokenizer"%>
<%@page import="com.liferay.portal.service.ListTypeServiceUtil"%>
<%@page import="java.util.List"%>
<%@page import="com.liferay.portal.model.ListType"%>
<%

ListType mappedFee = (ListType) request.getAttribute("mappedFee");

System.out.println("doing ID >>>" + mappedFee.getListTypeId());

List<ListType> mappedSubFees = 
	ListTypeServiceUtil.getListTypes
		("com.teqbridgeltd.liferay.model.map.Fees." + mappedFee.getName() );
System.out.println("com.teqbridgeltd.liferay.model.map.Fees." + mappedFee.getName() +"<<<");

%>
<!-- We will be having different JSP pages for each of the peculiar fees types -->

<% if("Capital Gains Tax".equalsIgnoreCase(mappedFee.getName())) {%>

<%} %>


		<tr>
		<td><b><span id="label"><%=mappedFee.getName() %> </span></b></td></tr>
		<!--  this is the fees description -->
			<td  width="200%" > 
				<%
				if("Capital Gains Tax".equalsIgnoreCase(mappedFee.getName())){
				%>
				<br>
				<input type="hidden" id="cgtTax" name="cgtTax" value="0.01"/>
				<jsp:include page="/html/calculator/capital_gain_tax.jsp"/>
				
				<%
				}
				else if("Processing Fees for Merger".equalsIgnoreCase(mappedFee.getName())
						||"Capital Gains Tax for Surrender".equalsIgnoreCase(mappedFee.getName())
						||"Processing Fees for Subdivision (Developed land)".equalsIgnoreCase(mappedFee.getName())){
				%>
				<jsp:include page="/html/calculator/Processing_fee_for_merger.jsp"/>
				<%
				}else if("Survey Fees".equalsIgnoreCase(mappedFee.getName())){
					%>
					<br/>
					
				     <jsp:include page="/html/calculator/survey_fees.jsp"/>
					<%
					}
					%>
				</td>
			<td>	
			
			<!-- this is if there is drop down -->		
			<%
			if(mappedSubFees.size() >= 2){
			%>
			
			<%
			
			//this is added to ensure that we use the compute button
			if ("Survey Fees".equalsIgnoreCase(mappedFee.getName())){ %>
			<select  id="purpose_<%=mappedFee.getListTypeId() %>"  name="purpose_<%=mappedFee.getListTypeId() %>">
			
			<%}else{
			
				//this is the default
			%>
			<select  onChange="pickFee(this, <%=mappedFee.getListTypeId() %>);"  id="purpose_<%=mappedFee.getListTypeId() %>"
					 name="purpose_<%=mappedFee.getListTypeId() %>"    >
			
			<%} %>
			<%
			for(int h=0; h<mappedSubFees.size(); h++){
				ListType mappedSubFee = mappedSubFees.get(h);
				String name = mappedSubFee.getName();
				StringTokenizer strTok = new StringTokenizer(name, "~");
				String firstPart, secondPart, fees;
				firstPart= secondPart= fees ="";
				try{
					 firstPart = strTok.nextToken().replaceAll(mappedFee.getName(), "");
					 secondPart = strTok.nextToken();
					 fees = strTok.nextToken();
				}catch(Exception ex){
					
				}
				
			%>
			<option 
                  value="<%= fees %>"><%=firstPart  %></option>
                
            <%
			}
            %>
                 		
			</select>
			
			<%
			}
			%>
			</td>
			
			
			<!-- This for displaying of the result -->
			<td>
			<%
			if(mappedSubFees.size() >= 2){
			%>
			<%=mappedFee.getListTypeId() %>fff
			<input id="result_<%=mappedFee.getListTypeId() %>" name="result_<%=mappedFee.getListTypeId() %>" type="text">
			<%
			}else if(mappedSubFees.size() == 1) {
				
				ListType mappedSubFee = mappedSubFees.get(0);
				StringTokenizer strTok = new StringTokenizer(mappedSubFee.getName(), "~");
				String firstPart, secondPart, fees;
				firstPart= secondPart= fees ="";
				try{
					 firstPart = strTok.nextToken(); //.replaceAll(mappedFee.getName(), "");
					 secondPart = strTok.nextToken();
					 fees = strTok.nextToken();
				}catch(Exception ex){
					
				}
			%>
			<%=mappedFee.getListTypeId() %>ggg
			<input name="result_<%=mappedFee.getListTypeId() %>"  id="result_<%=mappedFee.getListTypeId() %>" type="text" value="<%=fees %>">
			<%}
			%>
			
			</td>
		</tr>